package test;

public class Demo7 {

    public static void main(String[] args) {
        boolean palindrome = isPalindrome("ab_a");

        System.out.println(palindrome);
    }

    public static boolean isPalindrome(String s) {
        StringBuffer stringBuffer = new StringBuffer(s.replaceAll("\\W", "").replace("_",""));
        String s2 = new String(stringBuffer);
        String s1 = stringBuffer.reverse().toString().toLowerCase();

        return s2.toLowerCase().equals(s1);

    }
}
